const seq = require('../db/seq');
const Idea = require('../model/idea');

const idea = Idea(seq);

class IdeaController {
    //提交意见
    async submit(ctx, next) {
        const user_id = ctx.state.user.user_id;
        const { idea_info, idea_time } = ctx.request.body;
        try {
            const res = await idea.create({ user_id, idea_info, idea_time })
            ctx.body = {
                code: 0,
                message: '意见提交成功',
                result: res
            }
        } catch (err) {
            console.log('意见提交失败', err);
            return ctx.body = {
                error: '意见提交失败'
            }
        }

    }
}

module.exports = new IdeaController();